package com.spring.sso.config.common;

import com.spring.sso.config.security.authentication.JwtTokenService;
import com.spring.sso.mapper.SecurityRoleEntityMapper;
import com.spring.sso.mapper.SecurityUserEntityMapper;
import com.spring.sso.mapper.SecurityUserRoleEntityMapper;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.ConfigurableEnvironment;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.web.client.RestTemplate;

import javax.annotation.Resource;
import javax.sql.DataSource;

/**
 * @author : pangfuzhong
 * @description
 * @date : 2021/9/20 16:35
 */
@Configuration
@Data
public class AuthenticationConfig {

    @Value("${login_auth_url}")
    private String loginAuthUrl;

    @Value("${oauth_login_url}")
    private String oauthLoginUrl;

    @Value("${logout_auth_url}")
    private String logoutAuthUrl;

    @Value("${token_auth_url}")
    private String tokenAuthUrl;

    @Value("${verification_auth_url}")
    private String verificationAuthUrl;

    @Value("${white_list_url}")
    private String whiteListUrl;

    // 该配置模式参照AuthorizationEndpoint类的 userApprovalPage 属性  如：forward:/templates/login.html，暂时没有注释掉
   /* @Value("${oauth_user_approval_page}")
    private String oauthUserApprovalPage;*/

    // 该配置模式参照AuthorizationEndpoint类的 errorPage 属性 如：forward:/oauth/error，暂时没有注释掉
    /*@Value("${oauth_error_page}")
    private String oauthErrorPage;*/

    @Value("${token_expire_time}")
    private Integer tokenExpireTime;

    @Value("${token_expire_time_unit}")
    private String tokenExpireTimeUnit;

    @Value("${saas_auth_user_token-header-name}")
    private String tokenKey;

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private UserDetailsService userDetailsService;

    @Autowired
    private ConfigurableEnvironment configurableEnvironment;

    //@Resource(name = "redisTemplateHailiang")
    @Autowired
    private RedisTemplate redisTemplate;

    @Autowired
    private DataSource dataSource;

    @Autowired
    private JwtTokenService jwtTokenService;

    @Autowired
    private SecurityUserEntityMapper securityUserEntityMapper;

    @Autowired
    private SecurityUserRoleEntityMapper securityUserRoleEntityMapper;

    @Autowired
    private SecurityRoleEntityMapper securityRoleEntityMapper;

}
